<?php
/*
  $Program: ECJC Online Shop
  $Id: popup_products.php
  $Based on: osCommerce, Open Source E-Commerce Solutions
  Released under the GNU General Public License
  language issue exists
*/
  defined( 'JOSCOM_VERSION' ) or die( 'Direct Access to this location is not allowed.' );
  if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' )
  | $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_banners' ))) {
    //j15nc
  }
  if (defined( '_OSCOMMERCE_LOADED' )) {
    if (!DB_SHARED) {
      tep_db_connect() or die('Unable to connect to database server!');
    }
    global $category_links, $languages_id, $cPath, $cPath_array, $current_category_id;
    global $request_type, $lng, $cart, $currencies, $language, $navigation, $breadcrumb;
  } else {
    require(DIR_WS_COMPONENT . 'includes/application_top.php');
  }

?>

<style type="text/css">
<!--
h4 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; text-align: center}
p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
th {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
td {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
-->
</style>
<link rel="stylesheet" type="text/css" href="<?php echo DIR_WS_COMPONENT ?>includes/stylesheet.css">
<script language="JavaScript">
	function ClickEvent(products_id) {	
		oForms=window.opener.document.forms;
		for(i=0;i<oForms.length;i++) {
			if(oForms[i]["products_id"]) {
				sProductsId=oForms[i]["products_id"];
			  for(j=0;j<sProductsId.length;j++)
			    if(sProductsId.options[j].value==products_id) {
				  sProductsId.selectedIndex=j;
					window.close();
				}
			}
		}
	}
</script>

<table width="550" border="1" align="center" cellspacing="1" bordercolor="gray">
	<tr>
		<td colspan="3" align="center">
			<h4>Product Search:</h4>
			<form action="" method="post" enctype="multipart/form-data">
				Search: <input type="text" name="search"> <input type="submit" name="submit"><br><br>
			</form>
		</td>
	</tr>
    <tr>
		<th align="left" width="20%">&nbsp;&nbsp;<font color="0000FF">Products ID</th></font>
		<th align="left" width="40%">&nbsp;&nbsp;<font color="0000FF">Products Name</th></font>
		<th align="left" width="40%">&nbsp;&nbsp;<font color="0000FF">Products Model</th></font>
	</tr>
<?php 
  if(!empty($_REQUEST['search'])) {
	$result = tep_db_query("SELECT * FROM ". TABLE_PRODUCTS ." p, ". TABLE_PRODUCTS_DESCRIPTION ." pd WHERE pd.products_name like '%" . tep_db_input($_REQUEST['search']) . "%' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' ORDER BY pd.products_name");
    if ($row = tep_db_fetch_array($result)) {
        do {
?>
	<tr>
		<td>&nbsp;&nbsp;<a href="#" onClick="javascript:ClickEvent(<?php echo($row["products_id"]); ?>);"><?php echo($row["products_id"]); ?></a></td>
		<td>&nbsp;&nbsp;<a href="#" onClick="javascript:ClickEvent(<?php echo($row["products_id"]); ?>);"><font color="FF0000"><?php echo($row["products_name"]); ?></a></font></td>
		<td>&nbsp;&nbsp;<a href="#" onClick="javascript:ClickEvent(<?php echo($row["products_id"]); ?>);"><?php echo($row["products_model"]); ?></a></td>
	</tr>
<?php
        }
        while($row = tep_db_fetch_array($result));
    }
}
?>
</table>
<br>
</body>
</html>